<?php

class RoomStyles extends CActiveRecord
{
  /*
    id  key, each room''s id in one house style
    hs_id 户型id
    size_x  x轴长度
    size_y  y轴长度
    size_z  z轴长度
    position_x   the center 在x轴坐标
    position_y  the center 在y轴坐标
    position_z  the center 在z轴坐标
   */
 
 /*
   * Returns the static model of the specified AR class.
   * @return CActiveRecord the static model class
   */
  public static function model($className=__CLASS__)
  {
    return parent::model($className);
  }

  /**
   * @return string the associated database table name
   */
  public function tableName()
  {
    return 'ROOM_STYLES';
  }
  
  public function relations()
  {
  
  return array( 'housestyles'=>array(self::BELONGS_TO, 'HouseStyles', 'hs_id'),
                'FacilityRoom'=>array(self::HAS_MANY, 'FacilityRoom', 'rs_id','together'=>false));
  
  } 
   
  public function primaryKey(){
    return 'id';
  } 
  
  public function getRecordByHouseId($houseId){
     $record=self::model()->findAll('hs_id=:hs_id', array(':hs_id'=>$houseId));
     $array=array();
      foreach($record as $r){
      $object=new stdClass();
      $object->id=$r->id;
      $object->hs_id=$r->hs_id;
      $object->size_x=$r->size_x;
      $object->size_y=$r->size_y;
      $object->size_z=$r->size_z;
      $object->position_x=$r->position_x;
      $object->position_y=$r->position_y;
      $object->position_z=$r->position_z;
      $object->roomType=$r->roomType;
      array_push($array,$object);
     } 

    return $array;
  }
  
  }
  ?>